﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace telWebBrowserNet.Lib.TeleDLL
{

    /// <summary>
    /// 电话机盒子操作类,在这里引入TeleDll.dll文件
    /// </summary>
    public class TeleDll
    {
        #region DllImport
        /* [DllImport("TeleDll.dll")]
         private static extern int GetDeviceCount();*/

        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int GetDeviceCount();


        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int OpenDevice(int nDeviceIndex);//返回设备句柄


        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int CloseDevice(int pDeviceHandle);//关闭USB设备



        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int GetDeviceStatus(int pDeviceHandle);


        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int WriteStr(int pDeviceHandle, string szStr);


        [DllImport("TeleDll.dll", CallingConvention = CallingConvention.Winapi)]
        public static extern int ReadStr(int pDeviceHandle, StringBuilder szStr, uint dwTimeoutMs);

        #endregion

    }

}
